<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

    Route::get('push', 'UserController@pusher');

    Route::post('register', 'Auth\RegisterController@register');
    Route::post('login','Auth\LoginController@authenticate');
    Route::get('logout','Auth\LoginController@logout')->middleware('jwt.api.auth');
    Route::post('reset','Auth\ResetPasswordController@reset')->middleware('jwt.api.auth');

    //需要token验证的api放这里
    Route::group(['middleware' => 'jwt.api.auth'], function () { //
        Route::group(['prefix' => 'user'], function () { //
            Route::get('/info', 'UserController@personalInformation');
            Route::get('/borrow/record', 'UserController@borrowRecord');
            Route::post('/change/state', 'UserController@changeStateOfCommonUser')->middleware('admin');
            Route::get('/list', 'UserController@userList')->middleware('admin');
            Route::post('/not/return','UserController@userBorrowedRecord')->middleware('admin');
        });

        //图书管理相关api
        Route::group(['middleware' => ['checkAuth'], 'prefix' => 'manageBooks'], function () {
            Route::post('addCategory', 'CategoryController@addCategory');

            Route::post('addBooks', 'BooksController@addBooks');
            Route::get('bookList','BooksController@bookList');
            Route::post('deleteBooks','BooksController@deleteBooks');
            Route::post('increaseBooks','BooksController@increaseBooks');
            Route::post('searchBooks','BooksController@searchBooks');
            Route::get('increaseList','BooksController@increaseList');
            Route::get('deleteList','BooksController@deleteList');
            });

        Route::group(['prefix' => 'manageBooks'], function () {
            Route::get('categoryList','CategoryController@categoryList');
            Route::post('categoryDetail','CategoryController@categoryDetail');
            Route::get('bookList', 'BooksController@bookList');
            Route::post('searchBooks', 'BooksController@searchBooks');
        });

        Route::group(['prefix' => 'book'], function () {
            Route::post('borrow', 'BooksController@borrowBooks');
            Route::post('return', 'BooksController@returnBooks')->middleware('admin');

        });

    });

Route::group(['prefix' => 'alipay'], function () {
    Route::get('return', 'PayController@getReturn');
    Route::get('index','PayController@index');
    Route::get('notify', 'PayController@returnBooks');
});

Route::post("img/cut","ImgController@cut");




